<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 在JavaScript中，类的方法必须使用函数形式定义，而不能使用键值对形式
      // class是一个语法糖
      class People {
        constructor(name, age) {
          this.name = name
          this.age = age
        }
        sayHi() {
          console.log('你好啊')
        }
        jump() {
          console.log('大摆锤舞蹈')
        }
        // 静态方法
        static displayName = 'Point'
        static fun() {
          console.log('真好玩')
        }

        //私有属性
        #hello = 'hello'
        #sayWord() {
          console.log(this.#hello)
        }
      }

      class Teacher extends People {
        constructor(name, age, lesson) {
          super(name, age) // 借调 父构造函数的实例属性
          this.lesson = lesson
        }
        teach() {
          console.log('我会教书')
        }
      }
      const teacher = new Teacher('刘军', 57, '语文')
      console.log(teacher)
    </script>
  </body>
</html>
